package yf.mall.enums.app;

import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;
import java.util.stream.Stream;


/**
 * 
 * 
 * @date Wed Aug 23 15:59:30 CST 2023
 */
@Getter
public enum KolOrderFlowPointEnum {


    PAY_SUCC("PAY_SUCC", "支付完成"),


    REFUND("REFUND", "退款"),


    SETTLE("SETTLE", "结算"),


    CONFIRM("CONFIRM", "确认收货");


    String index;
    String value;

    public static String[] names() {
        return Arrays.stream(KolOrderFlowPointEnum.values()).map(m -> m.getValue()).toArray(String[]::new);
    }

    KolOrderFlowPointEnum(String index, String value) {
        this.index = index;
        this.value = value;
    }

    public static int nameOf(String name) {
        Integer res = null;
        for (int i = 0; i < names().length; i++) {
            if (names()[i].equals(name)) {
                res = i;
                break;
            }
        }
        return res;
    }

    public static String indexOf(String idx) {
        return Stream.of(KolOrderFlowPointEnum.values()).filter(typeEnum -> Objects.equals(idx, typeEnum.getIndex())).map(KolOrderFlowPointEnum::getValue).findFirst().orElse("");
    }

}
